
clear; clc;
addpath(fullfile(pwd, '..', 'lib'));
 datasetsAio = { 'bbcnewssport_737n_1000d_5c_uni_12k','RELATHE_1427n_4322d_2c_tfidf_uni_12k',...
    'warpPIE10P_210n_2420d_10c_12k','COIL20_1440n_1024d_20c_uni_12k',...
    'UMIST_575n_644d_20c_12k','BASEHOCK_1993n_4862d_2c_tfidf_uni_12k',...
     'leukemia_72n_7070d_2c_12k','ALLAML_72n_7129d_2c_12k',...   
};            
 indicator={'acc_lkgr_res','nmi_lkgr_res','purity_lkgr_res'}             
for i1 = 1:length(datasetsAio)
    load(fullfile(pwd, '..', 'data', datasetsAio{i1}));
    load(fullfile(pwd, '..', 'lkgr_res.mat'));
    nRepeat = 1;
    for ind=1:3        
    s=eval([indicator{ind}]);
    alphas =s(i1,1) % trade-off
    betas =s(i1,2); % local regularization
    gammas =s(i1,3);
    mus = 10.^[-2];
    Ks2 = zeros(size(Ks));
    for i2 = 1:size(Ks,3)
        Ktmp = knorm(Ks(:,:,i2));
        if max(Ktmp(:)) > 1
            Ktmp = Ktmp  / max(Ktmp(:));
        end
        Ks2(:,:,i2) = Ktmp;
    end

    [res_lkgr, timeElapsed1, res_lkgr_aio,biaozhuncha,fangcha] = LKGr_single_dataset(Ks2, Y, alphas, betas, gammas, mus, nRepeat);
    res_lkgr_aio=res_lkgr_aio(:,ind);
    biaozhuncha=biaozhuncha(:,ind);
    fangcha=fangcha(:,ind);
    res_lkgr=res_lkgr(:,ind);
    save(['..\','metricresult\',datasetsAio{i1},'_', indicator{ind},'_.mat'],  'res_lkgr_aio','res_lkgr');
              save([datasetsAio{i1},'_', indicator{ind},'_.mat'],  'res_lkgr_aio','res_lkgr');
    end
end